package com.cat.dataStructure03;

import java.io.*;
import java.util.Arrays;
import java.util.List;

/**
 * @author 曲大人的喵
 * @description https://www.luogu.com.cn/problem/P4281
 * @create 2025/11/20 12:57
 * @since JDK17
 */

public class Solution93 {
    static int MAXN = 500001, LIMIT = 19, cnt, n, m, power, together;
    static long cost;
    static int[] head = new int[MAXN], to = new int[MAXN << 1], next = new int[MAXN << 1], deep = new int[MAXN];
    static int[][] stjump = new int[MAXN][LIMIT];
    static void build() {
        cnt = 1;
        power = log2(n);
        Arrays.fill(head, 1, n + 1, 0);
    }

    static int log2(int n) {
        int ans = 0;
        while ((1 << ans) <= (n >> 1)) {
            ans++;
        }
        return ans;
    }

    static void add(int u, int v) {
        next[cnt] = head[u];
        to[cnt] = v;
        head[u] = cnt++;
    }

    static void dfs(int u, int f) {
        deep[u] = deep[f] + 1;
        stjump[u][0] = f;
        for (int p = 1; p <= power; p++) {  // 构建st表
            stjump[u][p] = stjump[stjump[u][p - 1]][p - 1];
        }
        for (int e = head[u]; e != 0; e = next[e]) {
            if (to[e] != f) {
                dfs(to[e], u);
            }
        }
    }
    static int lca(int x, int y) {
        if (deep[x] < deep[y]) {
            int temp = x;
            x = y;
            y = temp;
        }
        for (int p = power; p >= 0; p--) {  // 先跳到一起去
            if (deep[stjump[x][p]] >= deep[y]) {
                x = stjump[x][p];
            }
        }
        if (x == y) {
            return x;
        }
        for (int p = power; p >= 0; p--) {
            if (stjump[x][p] != stjump[y][p]) {
                x = stjump[x][p];
                y = stjump[y][p];
            }
        }

        return stjump[x][0];
    }
    static void compute(int a, int b, int c) {
        int x = lca(a, b), y = lca(a, c), z = lca(b, c);
        int high = x != y ? (deep[x] < deep[y] ? x : y) : x;
        int low = x != y ? (deep[x] > deep[y] ? x : y) : z;
        together = low;
        cost = (long) deep[a] + deep[b] + deep[c] - 2 * deep[high] - deep[low];
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        in.nextToken();
        n = ((int) in.nval);
        in.nextToken();
        m = ((int) in.nval);
        build();
        for (int i = 1, x, y; i < n; i++) {
            in.nextToken();
            x = ((int) in.nval);
            in.nextToken();
            y = ((int) in.nval);
            add(x, y);
            add(y, x);
        }
        dfs(1, 0);
        for (int i = 0, x, y, z; i < m; i++) {
            in.nextToken();
            x = ((int) in.nval);
            in.nextToken();
            y = ((int) in.nval);
            in.nextToken();
            z = ((int) in.nval);
            compute(x, y, z);
            out.println(together + " " + cost);
        }

        out.flush();
        out.close();
        br.close();
    }
}
